﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using MultiApp.UserControls;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace MultiApp
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MainPage : Page
    {
        Windows.ApplicationModel.Resources.ResourceLoader loader = new Windows.ApplicationModel.Resources.ResourceLoader("Strings");
        public MainPage()
        {
            this.InitializeComponent();
            changeGrid.Children.Add(new CurrencyControl());
            SetText();
        }

        private void SetText()
        {
            btnCalculator.Content = loader.GetString("btnCalculator");
            btnCurrency.Content = loader.GetString("btnCurrency1")+Environment.NewLine+loader.GetString("btnCurrency2");
            btnTimezone.Content = loader.GetString("btnTimezone");
            btnUnit.Content = loader.GetString("btnUnit");
            btnTranslate.Content = loader.GetString("btnTranslate");
        }

        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        private void btnCurrency_Click(object sender, RoutedEventArgs e)
        {
            var cur = new CurrencyControl();
            changeGrid.Children.Clear();
            changeGrid.Children.Add(cur);
        }

        private void btnUnit_Click(object sender, RoutedEventArgs e)
        {
            var un = new UnitControl();
            changeGrid.Children.Clear();
            changeGrid.Children.Add(un);
        }

        private void btnTimezone_Click(object sender, RoutedEventArgs e)
        {
            var ti = new TimezoneControl();
            changeGrid.Children.Clear();
            changeGrid.Children.Add(ti);
        }

        private void btnCalculator_Click(object sender, RoutedEventArgs e)
        {
            var ca = new CalculatorControl();
            changeGrid.Children.Clear();
            changeGrid.Children.Add(ca);
        }

        private void btnTranslate_Click(object sender, RoutedEventArgs e)
        {
            var tr = new TranslationControl();
            changeGrid.Children.Clear();
            changeGrid.Children.Add(tr);
        }

        private void onSizeChange(object sender, SizeChangedEventArgs e)
        {
            var currentViewState = Windows.UI.ViewManagement.ApplicationView.Value;
            var snapped = Windows.UI.ViewManagement.ApplicationViewState.Snapped;
            var filled = Windows.UI.ViewManagement.ApplicationViewState.Filled;
            if(currentViewState==snapped)
            {
                snapImg.Visibility = Visibility.Visible;
            }
            else
            {
                snapImg.Visibility = Visibility.Collapsed;
            }
            if (currentViewState==filled)
            {
                //kindasnap.Visibility=Visibility.Visible;

            }
            else
            {
                kindasnap.Visibility=Visibility.Collapsed;
            }

        }

    }
}
